<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>es6对象的新特性</title>
</head>
<body>
<script>
    //1.首先对象属性和方法的简写
    //1.1 es5之前的写法
    // const student = {
    //     name: 'Tom',
    //     age: 20,
    //     sayHello: function() {
    //         console.log(`Hello, my name is ${this.name}`);
    //     }
    // }
    //1.2 es6属性和方法的简写
    const name = 'Tom';
    const age = 20;

    // const student = {
    //     name: name, // 属性和取值同名触发简写方式
    //     age: age,
    //     sayHello() {
    //         console.log(`Hello, my name is ${this.name}`);
    //     }
    // }
    const student = {
        name, // 属性和取值同名触发简写方式
        age,
        sayHello() {
            console.log(`Hello, my name is ${this.name}`);
        }
    }

    console.log(student);
    student.sayHello();


    //对象的is()方法
    console.log(NaN === NaN)  //false
    var flag = Object.is(NaN, NaN);
    console.log(flag);  //true

    //对象的assign()方法 对象的浅拷贝
    const assign = Object.assign({}, {a:1},{b:2,c:3});
    console.log(assign);
</script>
</body>
</html>